package user

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Query(c *gin.Context) {
	//声明接收变量
	var arg user

	//传入结构体接受值,这里需要传入地址
	err := c.ShouldBind(&arg)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"msg": err.Error(),
		})
	} else {
		arg.Addr = "福建省厦门市"
		c.JSON(http.StatusOK, arg)
	}
}

type user struct {
	Name string `form:"name"`
	Age  int    `form:"age" json:"age"`
	Addr string `json:"addr"`
}
